package com.q.springboot.project.controller;

import com.q.springboot.framework.annotation.ResponseResult;
import com.q.springboot.project.entity.TUser;
import com.q.springboot.project.service.SpringRetryAnnotationService;
import com.q.springboot.project.service.TUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TUser)表控制层
 *
 * @author makejava
 * @since 2020-06-21 19:18:19
 */
@RestController
@RequestMapping("tUser")
@ResponseResult
//@JwtToken
public class TUserController {
    /**
     * 服务对象
     */
    @Resource
    private TUserService tUserService;
    @Resource
    private SpringRetryAnnotationService service;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne/{id}")
    public TUser selectOne(@PathVariable("id") Integer id) {
        return this.tUserService.queryById(id);
    }

    @GetMapping("/testToken")
    public String testToken(String token) {
        return "token验证成功";
    }

    @GetMapping("/selectAll")
    public List<TUser> selectAll(String token) {
        return this.tUserService.queryAll(null);
    }

    @GetMapping("/a")
    public Object a(String token) throws InterruptedException {
        tUserService.async();
        return "hhh";
    }

    @GetMapping("/he")
    public Object he(String token) throws InterruptedException {
        service.test("canshu");
        return "hhh";
    }

}